home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-10-28 | 63.5 KB | 2,093 lines |
- *** ./etc/ctags.1 Fri Jul 17 12:58:29 1992
- --- ../emacs-19.34/./etc/ctags.1 Fri May 15 12:03:09 1998
- ***************
- *** 1 ****
- ! .so man1/etags.1
- --- 1 ----
- ! .so etags.1
- *** ./etc/gnuserv.1 Thu May 21 11:32:03 1998
- --- ../emacs-19.34/./etc/gnuserv.1 Fri May 15 14:18:35 1998
- ***************
- *** 0 ****
- --- 1,132 ----
- + .TH GNUSERV 1 "" "GNU Emacs Server"
- + .UC 4
- + .SH NAME
- + gnuserv, gnuclient, gnudoit \- Server and Clients for GNU Emacs
- + .SH SYNOPSIS
- + .B gnuclient
- + [-q] [[-h hostname] [-p port] [-r pathname]] [[+line] path] ...
- + .br
- + .B gnudoit
- + [-q] [[-h hostname] [-p port]] [sexpr] ...
- + .br
- + .B gnuserv
- + .SH DESCRIPTION
- + \fIgnuclient\fP allows the user to request a running GNU Emacs process to edit
- + the named files or directories.
- + .PP
- + \fIgnudoit\fP allows the user to request a running GNU Emacs process to
- + evaluate the given arguments inside a progn LISP form.
- + .PP
- + \fIgnuserv\fP is the server program that is set running by GNU Emacs to handle
- + all incoming and outgoing requests. It is not usually invoked directly, but is
- + started from GNU Emacs by the LISP form (server-start).
- + .SH OPTIONS
- + .TP 8
- + .BI \-q
- + This option informs both \fIgnuclient\fP and \fIgnudoit\fP to exit once
- + connection has been made with the GNU Emacs process. Normally \fIgnuclient\fP
- + waits until all of the files on the command line have been finished with
- + (their buffers killed) by the GNU Emacs process, and \fIgnudoit\fP normally
- + waits around for evaluation of its arguments by the GNU Emacs process, and
- + prints the results or error conditions.
- + .TP 8
- + .BI \-h " hostname"
- + Used only with Internet-domain sockets, this option specifies the host machine
- + which should be running \fIgnuserv\fP. If this option is not specified then
- + the value of the environment variable GNU_HOST is used if set, otherwise the
- + hostname of the machine running the program is used.
- + .br
- + Note that an internet address may be specified instead of a hostname which can
- + speed up connections to the server by quite a bit, especially if the client
- + machine is running YP.
- + .br
- + Note also that a hostname of \fBunix\fP can be used to specify that the connection
- + to the server should use a Unix-domain socket (if supported) rather than an
- + Internet-domain socket.
- + .TP 8
- + .BI \-p " port"
- + Used only with Internet-domain sockets, this option specifies the service port
- + used to communicate between server and clients. If this option is not
- + specified, then the value of the environment variable GNU_PORT is used, if
- + set, otherwise a service called ``gnuserv'' is looked up
- + in the services database. Finally, if no other value can be found for the
- + port, then a default port is used which is usually 21490 + uid.
- + .br
- + Note that since \fIgnuserv\fP doesn't allow command-line options, the port for
- + it will have to be specified via one of the alternative methods.
- + .TP 8
- + .BI \-r " pathname"
- + Used only with Internet-domain sockets, the pathname argument may be needed to
- + inform GNU Emacs how to reach the root directory of a remote machine.
- + \fIgnuclient\fP prepends this string to each path argument given. For example,
- + if you were trying to edit a file on a client machine called otter, whose root
- + directory was accessible from the server machine via the path /net/otter, then
- + this argument should be set to '/net/otter'. If this option is omitted, then
- + the value is taken from the environment variable GNU_NODE, if set, or the
- + empty string otherwise.
- + .br
- + Note that on hp9000/s300 and hp9000/s800, the pathname, if not specified by
- + the user, is guessed.
- + .TP 8
- + .BI "path"
- + This is the path of the file to be edited. If the file is a directory, then
- + the directory browsers dired or monkey are usually invoked instead.
- + .TP 8
- + .BI "sexpr"
- + This is part of a GNU Emacs LISP expression to evaluate. All the sexprs are
- + concatenated together and wrapped in a progn form before sending to GNU Emacs.
- + .PP
- + .SH SETUP
- + In order to use the programs, the file gnuserv.el can be copied into a
- + directory on your GNU Emacs load-path, and loaded into GNU Emacs by the GNU
- + Emacs LISP form (load "gnuserv"). The server can then be started by the GNU
- + Emacs LISP form (server-start).
- + .SH EXAMPLE
- + .TP 8
- + gnudoit -q '(mh-smail)'
- + .TP 8
- + gnuclient -h otter -r /net/otter /tmp/*
- + .SH SYSV IPC
- + SysV IPC is used to communicate between \fIgnuclient\fP, \fIgnudoit\fP and
- + \fIgnuserv\fP if the symbol SYSV_IPC is defined at the top of gnuserv.h. This
- + is incompatible with both Unix-domain and Internet-domain socket communication
- + as described below. A file called /tmp/gsrv??? is created as a key for the
- + message queue, and if removed will cause the communication between server and
- + client to fail until the server is restarted.
- + .SH UNIX-DOMAIN SOCKETS
- + A Unix-domain socket is used to communicate between \fIgnuclient\fP,
- + \fIgnudoit\fP and \fIgnuserv\fP if the symbol UNIX_DOMAIN_SOCKETS is defined
- + at the top of gnuserv.h. A file called /tmp/gsrv??? is created for
- + communication and if deleted will cause communication between server and
- + client to fail.
- + .SH INTERNET-DOMAIN SOCKETS
- + Internet-domain sockets are used to communicate between \fIgnuclient\fP,
- + \fIgnudoit\fP and \fIgnuserv\fP if the symbol INTERNET_DOMAIN_SOCKETS is
- + defined at the top of gnuserv.h. Both Internet-domain and Unix-domain sockets
- + can be used at the same time.
- + .SH SECURITY
- + Using Internet-domain sockets, a more robust form of security is needed that
- + wasn't necessary with either Unix-domain sockets or SysV IPC.
- + .br
- + \fIgnuserv\fP performs a limited form of security at the machine level. By
- + default only connections from the host where the server is running will be
- + allowed. All other server connections will be rejected with a cryptic message
- + (which is displayed only by \fIgnudoit\fP). Alternatively, if the variable
- + GNU_SECURE can be found in \fIgnuserv\fP's environment, and it names a
- + readable filename, then this file is opened and assumed to be a list of hosts,
- + one per line, from which the server will allow requests. Note that a host may
- + be either a internet address, or a hostname. If this file contains a lot of
- + hostnames then the server may take quite a time to start up.
- + .SH KNOWN BUGS
- + If GNU Emacs attempts to send a string containing a newline character to
- + \fIgnuserv\fP, then \fIgnuserv\fP will die.
- + .SH FILES
- + .PP
- + .TP 8
- + .B /tmp/gsrv???
- + .TP 8
- + .B ~/.emacs
- + GNU Emacs customization file, see emacs(1).
- + .SH AUTHOR.
- + Andy Norman (ange@hplb.hpl.hp.com), based heavily upon etc/emacsclient.c,
- + etc/server.c and lisp/server.el from the GNU Emacs 18.52 distribution.
- *** ./src/m/iris4d.h Tue Jul 23 14:28:12 1996
- --- ../emacs-19.34/./src/m/iris4d.h Thu May 21 11:41:07 1998
- ***************
- *** 131,137 ****
-
- #undef LIBS_MACHINE
- /* -lsun in case using Yellow Pages for passwords. */
- ! #if defined(__GNUC__) && defined(_ABIN32)
- #define LIBS_MACHINE
- #else
- #define LIBS_MACHINE -lmld
- --- 131,137 ----
-
- #undef LIBS_MACHINE
- /* -lsun in case using Yellow Pages for passwords. */
- ! #if defined(_ABIN32)
- #define LIBS_MACHINE
- #else
- #define LIBS_MACHINE -lmld
- ***************
- *** 187,193 ****
- --- 187,197 ----
- that we can't fix without breaking other machines. */
- #ifdef IRIX_FORCE_32_BITS
- #ifdef THIS_IS_MAKEFILE
- + #ifdef _ABIN32
- + #define C_SWITCH_MACHINE -n32
- + #else
- #define C_SWITCH_MACHINE -32
- + #endif
- #endif
- #endif
-
- *** ./src/s/irix6-x.h Thu May 21 11:32:03 1998
- --- ../emacs-19.34/./src/s/irix6-x.h Thu May 21 11:42:19 1998
- ***************
- *** 0 ****
- --- 1,39 ----
- + #include "irix5-0.h"
- +
- + /* Irix 6 prior to 6.2 tries to do 64 bits, but doesn't do it fully,
- + so inhibit that. */
- + /* #define IRIX_FORCE_32_BITS */
- +
- + /* Define this for -n32, undef it for -o32 builds */
- + #define _ABIN32
- +
- + #ifdef _ABIN32
- + # ifndef __GNUC__
- + # define LD_SWITCH_SYSTEM -G0
- + # undef C_SWITCH_SYSTEM
- + # define C_SWITCH_SYSTEM -xansi -G0
- + # undef C_DEBUG_SWITCH
- + # endif
- + # undef LOADLIBES
- + #else
- + # undef C_SWITCH_SYSTEM
- + # define C_SWITCH_SYSTEM -mips2
- + # undef C_DEBUG_SWITCH
- + # define C_DEBUG_SWITCH -O2 -Olimit 3000
- + #endif
- +
- + /* This macro definition, which we inherited from irix5-0.h,
- + is needed in configure on Irix 5, but gets in the way there
- + on Irix 6. So get rid of it except in Makefile.in where we need it. */
- + #ifndef THIS_IS_MAKEFILE
- + # undef C_SWITCH_SYSTEM
- + #endif
- +
- + /* The only supported configuration of GCC under IRIX6.x produces
- + n32 MIPS ABI binaries and also supports -g. */
- + #ifdef __GNUC__
- + # undef C_DEBUG_SWITCH
- + # define C_DEBUG_SWITCH -g
- + #endif
- +
- + #undef SA_RESTART
- *** ./src/s/irix5-0.h Fri Jul 19 15:40:59 1996
- --- ../emacs-19.34/./src/s/irix5-0.h Fri May 15 11:53:42 1998
- ***************
- *** 3,8 ****
- --- 3,11 ----
- #define IRIX5
-
- /* We want BSD style signals. */
- + #ifdef _BSD_SIGNALS
- + #undef _BSD_SIGNALS
- + #endif
- #define _BSD_SIGNALS
-
- #define SETPGRP_RELEASES_CTTY
- *** ./src/Makefile.in Sat May 18 16:12:39 1996
- --- ../emacs-19.34/./src/Makefile.in Fri May 15 10:42:41 1998
- ***************
- *** 734,740 ****
- #ifdef HAVE_SHM
- ./temacs -nl -batch -l loadup dump
- #else /* ! defined (HAVE_SHM) */
- ! ./temacs -batch -l loadup dump
- #endif /* ! defined (HAVE_SHM) */
- #endif /* ! defined (CANNOT_DUMP) */
-
- --- 734,740 ----
- #ifdef HAVE_SHM
- ./temacs -nl -batch -l loadup dump
- #else /* ! defined (HAVE_SHM) */
- ! LD_LIBRARYN32_PATH=$(ROOT)/usr/lib32 ./temacs -batch -l loadup dump
- #endif /* ! defined (HAVE_SHM) */
- #endif /* ! defined (CANNOT_DUMP) */
-
- *** ./lib-src/Makefile.in Fri Jun 21 01:45:18 1996
- --- ../emacs-19.34/./lib-src/Makefile.in Fri May 15 10:42:41 1998
- ***************
- *** 88,100 ****
-
- # Things that a user might actually run,
- # which should be installed in bindir.
- ! INSTALLABLES = etags ctags emacsclient b2m
- INSTALLABLE_SCRIPTS = rcs-checkin
-
- # Things that Emacs runs internally, or during the build process,
- # which should not be installed in bindir.
- UTILITIES= profile digest-doc \
- ! sorted-doc movemail cvtmail fakemail yow emacsserver hexl
-
- DONT_INSTALL= test-distrib make-docfile
-
- --- 88,100 ----
-
- # Things that a user might actually run,
- # which should be installed in bindir.
- ! INSTALLABLES = etags ctags emacsclient b2m gnuclient gnudoit
- INSTALLABLE_SCRIPTS = rcs-checkin
-
- # Things that Emacs runs internally, or during the build process,
- # which should not be installed in bindir.
- UTILITIES= profile digest-doc \
- ! sorted-doc movemail cvtmail fakemail yow emacsserver hexl gnuserv
-
- DONT_INSTALL= test-distrib make-docfile
-
- ***************
- *** 374,379 ****
- --- 374,394 ----
-
- emacsclient: ${srcdir}/emacsclient.c ../src/config.h
- $(CC) ${ALL_CFLAGS} ${srcdir}/emacsclient.c $(LOADLIBES) -o emacsclient
- +
- +
- + /* ange's gnuserv stuff */
- +
- + gnuclient: gnuserv.h gnuslib.o gnuclient.c ../src/config.h
- + $(CC) -o gnuclient -I${srcdir}/../src ${ALL_CFLAGS} ${srcdir}/gnuclient.c gnuslib.o $(LOADLIBES)
- +
- + gnuserv: gnuserv.h gnuslib.o gnuserv.c ../src/config.h
- + $(CC) -o gnuserv -I${srcdir}/../src ${ALL_CFLAGS} ${srcdir}/gnuserv.c gnuslib.o $(LOADLIBES)
- +
- + gnudoit: gnuserv.h gnuslib.o gnudoit.c ../src/config.h
- + $(CC) -o gnudoit -I${srcdir}/../src ${ALL_CFLAGS} ${srcdir}/gnudoit.c gnuslib.o $(LOADLIBES)
- +
- + gnuslib.o: gnuserv.h gnuslib.c ../src/config.h
- + $(CC) -c -I${srcdir}/../src ${ALL_CFLAGS} ${srcdir}/gnuslib.c
-
- hexl: ${srcdir}/hexl.c
- $(CC) ${ALL_CFLAGS} ${srcdir}/hexl.c $(LOADLIBES) -o hexl
- *** ./lib-src/gnuclient.c Thu May 21 11:32:03 1998
- --- ../emacs-19.34/./lib-src/gnuclient.c Fri May 15 10:38:26 1998
- ***************
- *** 0 ****
- --- 1,249 ----
- + /* -*-C-*-
- + Client code to allow local and remote editing of files by GNU Emacs.
- +
- + This file is part of GNU Emacs.
- +
- + Copying is permitted under those conditions described by the GNU
- + General Public License.
- +
- + Copyright (C) 1989 Free Software Foundation, Inc.
- +
- + Author: Andy Norman (ange@hplb.hpl.hp.com), based on
- + 'etc/emacsclient.c' from the GNU Emacs 18.52 distribution.
- +
- + Please mail bugs and suggestions to the author at the above address.
- + */
- +
- + static char rcsid [] = "$Header: gnuclient.c,v 1.8 89/07/24 12:46:46 ange Exp $";
- +
- + #include "gnuserv.h"
- +
- + #if !defined(SYSV_IPC) && !defined(UNIX_DOMAIN_SOCKETS) && !defined(INTERNET_DOMAIN_SOCKETS)
- + main ()
- + {
- + fprintf (stderr,"Sorry, the Emacs server is only supported on systems that have\n");
- + fprintf (stderr,"Unix Domain sockets, Internet Domain sockets or System V IPC.\n");
- + exit (1);
- + } /* main */
- + #else /* SYSV_IPC || UNIX_DOMAIN_SOCKETS || INTERNET_DOMAIN_SOCKETS */
- +
- + static char cwd[MAXPATHLEN+2]; /* current working directory when calculated */
- + static char *cp = NULL; /* ptr into valid bit of cwd above */
- +
- +
- + /*
- + get_current_working_directory -- return the cwd.
- + */
- + char *get_current_working_directory()
- + {
- + if (cp == NULL) { /* haven't calculated it yet */
- + #ifdef BSD
- + if (getwd(cwd) == 0) {
- + #else /* !BSD */
- + if (getcwd(cwd,MAXPATHLEN) == NULL) {
- + #endif /* !BSD */
- + perror(progname);
- + fprintf(stderr,"%s: unable to get current working directory\n",progname);
- + exit(1);
- + }; /* if */
- +
- + /* on some systems, cwd can look like '@machine/' ... */
- + /* ignore everything before the first '/' */
- + for (cp = cwd; *cp && *cp != '/'; ++cp)
- + ;
- +
- + }; /* if */
- +
- + return cp;
- +
- + } /* get_current_working_directory */
- +
- +
- + /*
- + filename_expand -- try to convert the given filename into a fully-qualified
- + pathname.
- + */
- + void filename_expand(fullpath,filename)
- + char *fullpath; /* returned full pathname */
- + char *filename; /* filename to expand */
- + {
- + int len;
- +
- + fullpath[0] = '\0';
- +
- + if(filename[0] && filename[0] != '/') { /* relative filename */
- +
- + strcat(fullpath,get_current_working_directory());
- + len = strlen(fullpath);
- +
- + if (len > 0 && fullpath[len-1] == '/') /* trailing slash already? */
- + ; /* yep */
- + else
- + strcat(fullpath,"/"); /* nope, append trailing slash */
- + }; /* if */
- +
- + strcat(fullpath,filename);
- +
- + } /* filename_expand */
- +
- +
- + main(argc,argv)
- + int argc;
- + char *argv[];
- + {
- + int starting_line = 1; /* line to start editing at */
- + char command[MAXPATHLEN+50]; /* emacs command buffer */
- + char fullpath[MAXPATHLEN+1]; /* full pathname to file */
- + int qflg = 0; /* quick edit, don't wait for user to finish */
- + int errflg = 0; /* option error */
- + int c; /* char from getopt */
- + int s; /* socket / msqid to server */
- + #ifdef INTERNET_DOMAIN_SOCKETS
- + char thishost[HOSTNAMSZ]; /* this hostname */
- + char remotehost[HOSTNAMSZ]; /* remote hostname */
- + char remotepath[MAXPATHLEN+1]; /* remote pathname */
- + int hflg = 0; /* hostname given on command line */
- + int rflg = 0; /* pathname given on command line */
- + u_short port = 0; /* port to server */
- + char *ptr; /* return from getenv */
- + #endif /* INTERNET_DOMAIN_SOCKETS */
- + #ifdef SYSV_IPC
- + struct msgbuf *msgp; /* message */
- + #endif /* SYSV_IPC */
- +
- + progname = argv[0];
- +
- + while ((c = getopt(argc, argv,
- +
- + #ifdef INTERNET_DOMAIN_SOCKETS
- + "h:p:r:q"
- + #else /* !INTERNET_DOMAIN_SOCKETS */
- + "q"
- + #endif /* !INTERNET_DOMAIN_SOCKETS */
- +
- + )) != EOF)
- + switch (c) {
- + case 'q': /* quick mode specified */
- + qflg++;
- + break;
- +
- + #ifdef INTERNET_DOMAIN_SOCKETS
- + case 'h': /* server host name specified */
- + strcpy(remotehost,optarg);
- + hflg++;
- + break;
- + case 'r': /* remote path from server specifed */
- + strcpy(remotepath,optarg);
- + rflg++;
- + break;
- + case 'p': /* port number specified */
- + port = atoi(optarg);
- + break;
- + #endif /* INTERNET_DOMAIN_SOCKETS */
- +
- + case '?':
- + errflg++;
- + }; /* switch */
- +
- + if (errflg) {
- + fprintf(stderr,
- + #ifdef INTERNET_DOMAIN_SOCKETS
- + "usage: %s [-q] [-h hostname] [-p port] [-r pathname] [[+line] path] ...\n",
- + #else /* !INTERNET_DOMAIN_SOCKETS */
- + "usage: %s [-q] [[+line] path] ...\n",
- + #endif /* !INTERNET_DOMAIN_SOCKETS */
- + progname);
- + exit (1);
- + }; /* if */
- +
- + #ifdef INTERNET_DOMAIN_SOCKETS
- + gethostname(thishost,HOSTNAMSZ);
- +
- + if (!hflg) { /* attempt to find the server host */
- + if((ptr=getenv("GNU_HOST")) != NULL) /* user specified a host */
- + strcpy(remotehost,ptr);
- + else /* use this host by default */
- + strcpy(remotehost,thishost);
- + }; /* if */
- +
- + if(!rflg) { /* attempt to generate a path to this machine */
- + if((ptr=getenv("GNU_NODE")) != NULL) /* user specified a path */
- + strcpy(remotepath,ptr);
- +
- + #if defined(hp9000s300) || defined(hp9000s800)
- + else if (strcmp(thishost,remotehost)) { /* try /net/thishost */
- + strcpy(remotepath,"/net/"); /* (this fails using internet addresses) */
- + strcat(remotepath,thishost);
- + }
- + #endif
- +
- + else /* same machines, no need for path */
- + remotepath[0] = '\0'; /* default is the empty path */
- + }; /* if */
- +
- + if (port == 0 && (ptr=getenv("GNU_PORT")) != NULL)
- + port = atoi(ptr);
- +
- + #ifdef UNIX_DOMAIN_SOCKETS
- + if (!strcmp(remotehost,"unix"))
- + s = connect_to_unix_server();
- + else
- + #endif /* UNIX_DOMAIN_SOCKETS */
- + s = connect_to_internet_server(remotehost,port);
- + #else /* !INTERNET_DOMAIN_SOCKETS */
- +
- + #ifdef UNIX_DOMAIN_SOCKETS
- + s = connect_to_unix_server();
- + #endif /* UNIX_DOMAIN_SOCKETS */
- +
- + #ifdef SYSV_IPC
- + if ((msgp = (struct msgbuf *) malloc(sizeof *msgp + BUFSIZ)) == NULL) {
- + fprintf(stderr,"%s: not enough memory for message buffer\n",progname);
- + exit(1);
- + }; /* if */
- +
- + msgp->mtext[0] = '\0'; /* ready for later strcats */
- + s = connect_to_ipc_server();
- + #endif /* SYSV_IPC */
- +
- + #endif /* !INTERNET_DOMAIN_SOCKETS */
- +
- + if (qflg) {
- + send_string(s,"(server-edit-files-quickly '(");
- + }
- + else {
- + send_string(s,"(server-edit-files '(");
- + };
- +
- + for (; optind < argc; optind++) {
- + if (*argv[optind] == '+')
- + starting_line = atoi(argv[optind]);
- + else {
- +
- + filename_expand(fullpath,argv[optind]);
- + sprintf(command,"(%d . \"%s%s\")",starting_line,
- +
- + #ifdef INTERNET_DOMAIN_SOCKETS
- + remotepath,
- + #else /* !INTERNET_DOMAIN_SOCKETS */
- + "",
- + #endif
- + fullpath);
- + send_string(s,command);
- + starting_line = 1;
- + }; /* else */
- + }; /* for */
- +
- + send_string(s,"))");
- +
- + #ifdef SYSV_IPC
- + disconnect_from_ipc_server(s,msgp,FALSE);
- + #else /* !SYSV_IPC */
- + disconnect_from_server(s,FALSE);
- + #endif /* !SYSV_IPC */
- +
- + exit(0);
- +
- + } /* main */
- +
- + #endif /* SYSV_IPC || UNIX_DOMAIN_SOCKETS || INTERNET_DOMAIN_SOCKETS */
- *** ./lib-src/gnuserv.h Thu May 21 11:32:03 1998
- --- ../emacs-19.34/./lib-src/gnuserv.h Fri May 15 10:38:52 1998
- ***************
- *** 0 ****
- --- 1,102 ----
- + /* -*-C-*-
- + Header file for the GNU Emacs server and client C code.
- +
- + This file is part of GNU Emacs.
- +
- + Copying is permitted under those conditions described by the GNU
- + General Public License.
- +
- + Copyright (C) 1989 Free Software Foundation, Inc.
- +
- + Author: Andy Norman (ange@hplb.hpl.hp.com), based on
- + 'etc/server.c' and 'etc/emacsclient.c' from the 18.52 GNU
- + Emacs distribution.
- +
- + Please mail bugs and suggestions to the author at the above address.
- + */
- +
- + static char header_rcsid [] = "$Header: gnuserv.h,v 1.9 90/01/31 10:37:41 ange Exp $";
- +
- + #define NO_SHORTNAMES
- +
- + #define PATCHLEVEL 2
- +
- + #include "../src/config.h"
- + #undef read
- + #undef write
- + #undef open
- + #undef close
- +
- + /* Define the communication method between server and clients */
- +
- + #define INTERNET_DOMAIN_SOCKETS
- + #define UNIX_DOMAIN_SOCKETS
- + /* #define SYSV_IPC */
- +
- + #if !defined(SYSV_IPC) && !defined(UNIX_DOMAIN_SOCKETS) && !defined(INTERNET_DOMAIN_SOCKETS)
- +
- + #ifdef HAVE_SYSVIPC
- + #define SYSV_IPC /* SYSV systems use SYSV IPC by default */
- + #endif /* HAVE_SYSVIPC */
- +
- + #ifdef BSD
- + #define UNIX_DOMAIN_SOCKETS /* BSD systems use Unix Domain sockets by default */
- + #endif /* BSD */
- +
- + #endif /* No communication method pre-defined */
- +
- + #include <sys/types.h>
- + #include <sys/param.h>
- + #include <stdio.h>
- + #include <signal.h>
- +
- + #ifdef SYSV_IPC
- + #include <sys/ipc.h>
- + #include <sys/msg.h>
- +
- + #define send_string(s,str) \
- + if (strlen(msgp->mtext) + strlen(str) < BUFSIZ) \
- + strcat(msgp->mtext,str); \
- + else \
- + { \
- + fprintf(stderr,"%s: not enough message buffer space\n",progname); \
- + exit(1); \
- + } \
- +
- + #endif /* SYSV_IPC */
- +
- + #if defined(INTERNET_DOMAIN_SOCKETS) || defined(UNIX_DOMAIN_SOCKETS)
- + #include <sys/socket.h>
- + #endif /* INTERNET_DOMAIN_SOCKETS || UNIX_DOMAIN_SOCKETS */
- +
- + #ifdef INTERNET_DOMAIN_SOCKETS
- + #include <netinet/in.h>
- + #include <netdb.h>
- + #define TABLE_SIZE 101 /* The number of entries in the hash table */
- + #define HASH(host) host /* Rather simplistic hash function */
- + #define DEFAULT_PORT 21490 /* default port number to use */
- + #endif /* INTERNET_DOMAIN_SOCKETS */
- +
- + #ifdef UNIX_DOMAIN_SOCKETS
- + #include <sys/un.h>
- + #endif /* UNIX_DOMAIN_SOCKETS */
- +
- + #define HOSTNAMSZ 255 /* max size of a hostname */
- + #define REPLYSIZ 300 /* max size of reply from server to client */
- + #define FALSE 0
- + #define TRUE 1
- +
- + extern char *getenv();
- + extern char *optarg;
- + extern int optind;
- + extern char *progname;
- +
- + #ifndef BSD
- + extern char *getcwd();
- + #endif
- +
- + #define max2(x,y) (((x) > (y)) ? (x) : (y))
- +
- + #ifndef _NFILE /* rough guess at maximum number of open files */
- + #define _NFILE 20
- + #endif
- *** ./lib-src/gnuserv.c Thu May 21 11:32:03 1998
- --- ../emacs-19.34/./lib-src/gnuserv.c Fri May 15 10:38:48 1998
- ***************
- *** 0 ****
- --- 1,542 ----
- + /* -*-C-*-
- + Server code for handling requests from clients and forwarding them
- + on to the GNU Emacs process.
- +
- + This file is part of GNU Emacs.
- +
- + Copying is permitted under those conditions described by the GNU
- + General Public License.
- +
- + Copyright (C) 1989 Free Software Foundation, Inc.
- +
- + Author: Andy Norman (ange@hplb.hpl.hp.com), based on 'etc/server.c'
- + from the 18.52 GNU Emacs distribution.
- +
- + Please mail bugs and suggestions to the author at the above address.
- + */
- +
- + static char rcsid [] = "$Header: gnuserv.c,v 1.8 89/09/28 12:47:01 ange Exp $";
- +
- + #include "gnuserv.h"
- +
- + #if !defined(SYSV_IPC) && !defined(UNIX_DOMAIN_SOCKETS) && !defined(INTERNET_DOMAIN_SOCKETS)
- + main ()
- + {
- + fprintf (stderr,"Sorry, the Emacs server is only supported on systems that have\n");
- + fprintf (stderr,"Unix Domain sockets, Internet Domain sockets or System V IPC\n");
- + exit (1);
- + } /* main */
- + #else /* SYSV_IPC || UNIX_DOMAIN_SOCKETS || INTERNET_DOMAIN_SOCKETS */
- +
- + #ifdef SYSV_IPC
- +
- + int ipc_qid = 0; /* ipc message queue id */
- + int ipc_wpid = 0; /* watchdog task pid */
- +
- +
- + /*
- + ipc_exit -- clean up the queue id and queue, then kill the watchdog task
- + if it exists. exit with the given status.
- + */
- + void ipc_exit(stat)
- + int stat;
- + {
- + msgctl(ipc_qid,IPC_RMID,0);
- +
- + if (ipc_wpid != 0)
- + kill(ipc_wpid,SIGKILL);
- +
- + exit(stat);
- + } /* ipc_exit */
- +
- +
- + /*
- + ipc_handle_signal -- catch the signal given and clean up.
- + */
- + void ipc_handle_signal(sig)
- + int sig;
- + {
- + ipc_exit(0);
- + } /* ipc_handle_signal */
- +
- +
- + /*
- + ipc_spawn_watchdog -- spawn a watchdog task to clean up the message queue should the
- + server process die.
- + */
- + int ipc_spawn_watchdog()
- + {
- + if ((ipc_wpid = fork()) == 0) { /* child process */
- + int ppid = getppid(); /* parent's process id */
- +
- + setpgrp(); /* gnu kills process group on exit */
- +
- + while (1) {
- + if (kill(ppid,0) < 0) { /* ppid is no longer valid, parent may have died */
- + ipc_exit(0);
- + }; /* if */
- +
- + sleep(10); /* have another go later */
- + }; /* while */
- + }; /* if */
- +
- + } /* ipc_spawn_watchdog */
- +
- +
- + /*
- + ipc_init -- initialize server, setting the global msqid that can be listened on.
- + */
- + void ipc_init(msgpp)
- + struct msgbuf **msgpp;
- + {
- + key_t key; /* messge key */
- + char buf[BUFSIZ]; /* pathname for key */
- + int p; /* child process id */
- +
- + sprintf(buf,"/tmp/gsrv%d",geteuid());
- + creat(buf,0600);
- + key = ftok(buf,1);
- +
- + if ((ipc_qid = msgget(key,0600|IPC_CREAT)) == -1) {
- + perror(progname);
- + fprintf(stderr,"%s: unable to create msg queue\n",progname);
- + ipc_exit(1);
- + }; /* if */
- +
- + ipc_spawn_watchdog();
- +
- + signal(SIGTERM,ipc_handle_signal);
- + signal(SIGINT,ipc_handle_signal);
- +
- + if ((*msgpp = (struct msgbuf *) malloc(sizeof **msgpp + BUFSIZ)) == NULL) {
- + fprintf(stderr,"%s: unable to allocate space for message buffer\n",progname);
- + ipc_exit(1);
- + }; /* if */
- +
- + } /* ipc_init */
- +
- +
- + /*
- + handle_ipc_request -- accept a request from a client, pass the request on
- + to the GNU Emacs process, then wait for its reply and
- + pass that on to the client.
- + */
- + void handle_ipc_request(msgp)
- + struct msgbuf *msgp; /* message buffer */
- + {
- + struct msqid_ds msg_st; /* message status */
- + char buf[BUFSIZ];
- + int len; /* length of message / read */
- + int junk; /* junk value */
- +
- + if ((len = msgrcv(ipc_qid,msgp,BUFSIZ-1,1,0)) < 0) {
- + perror(progname);
- + fprintf(stderr,"%s: unable to receive\n",progname);
- + ipc_exit(1);
- + }; /* if */
- +
- + msgctl(ipc_qid,IPC_STAT,&msg_st);
- + strncpy(buf,msgp->mtext,len);
- + buf[len] = '\0'; /* terminate */
- +
- + printf("%d %s",ipc_qid,buf);
- + fflush(stdout);
- +
- + if ((len = read(0,buf,BUFSIZ)) < 0) {
- + perror(progname);
- + fprintf(stderr,"%s: unable to read\n",progname);
- + ipc_exit(1);
- + }; /* if */
- +
- + /* parse the response from gnu */
- + msgp->mtext[0] = '\0';
- + sscanf(buf,"%d:%[^\n]\n",&junk,msgp->mtext);
- +
- + /* Send a response back to the client. */
- + msgp->mtype = msg_st.msg_lspid;
- + msgsnd(ipc_qid,msgp,strlen(msgp->mtext)+1,0);
- +
- + } /* handle_ipc_request */
- + #endif /* SYSV_IPC */
- +
- +
- + #if defined(INTERNET_DOMAIN_SOCKETS) || defined(UNIX_DOMAIN_SOCKETS)
- + /*
- + echo_request -- read request from a given socket descriptor, and send the information
- + to stdout (the gnu process).
- + */
- + void echo_request(s)
- + int s; /* socket */
- + {
- + char buf[BUFSIZ];
- + int len;
- +
- + printf("%d ",s);
- +
- + /* read until we get a newline or no characters */
- + while ((len = recv(s,buf,BUFSIZ,0)) > 0) {
- + buf[len] = '\0';
- + printf("%s",buf);
- +
- + if (buf[len-1] == '\n')
- + break; /* end of message */
- +
- + }; /* while */
- +
- + if (len < 0) {
- + perror(progname);
- + fprintf(stderr,"%s: unable to recv\n",progname);
- + exit(1);
- + }; /* if */
- +
- + } /* echo_request */
- +
- +
- + /*
- + handle_response -- accept a response from stdin (the gnu process) and pass the
- + information on to the relevant client.
- + */
- + void handle_response()
- + {
- + char buf[BUFSIZ];
- + char response[BUFSIZ];
- + int s;
- + int len;
- +
- + if ((len = read(0,buf,BUFSIZ)) < 0) {
- + perror(progname);
- + fprintf(stderr,"%s: unable to read\n",progname);
- + exit(1);
- + }; /* if */
- +
- + /* parse the response from gnu */
- + response[0] = '\0';
- + sscanf(buf,"%d:%[^\n]\n", &s, response);
- +
- + /* Send a response back to the client. */
- + send_string(s,response);
- + close(s);
- +
- + } /* handle_response */
- + #endif /* INTERNET_DOMAIN_SOCKETS || UNIX_DOMAIN_SOCKETS */
- +
- +
- + #ifdef INTERNET_DOMAIN_SOCKETS
- + struct entry {
- + u_long host_addr;
- + struct entry *next;
- + };
- +
- + struct entry *permitted_hosts[TABLE_SIZE];
- +
- +
- + /*
- + permitted -- return whether a given host is allowed to connect to the server.
- + */
- + int permitted(host_addr)
- + u_long host_addr;
- + {
- + int key;
- + struct entry *entry;
- +
- + /* First find the hash key */
- + key = HASH(host_addr) % TABLE_SIZE;
- +
- + /* Now check the chain for that hash key */
- + for(entry=permitted_hosts[key]; entry != NULL; entry=entry->next)
- + if (host_addr == entry->host_addr)
- + return(TRUE);
- +
- + return(FALSE);
- +
- + } /* permitted */
- +
- +
- + /*
- + add_host -- add the given host to the list of permitted hosts, provided it isn't
- + already there.
- + */
- + void add_host(host_addr)
- + u_long host_addr;
- + {
- + int key;
- + struct entry *new_entry;
- +
- + if (!permitted(host_addr)) {
- + if ((new_entry = (struct entry *) malloc(sizeof(struct entry))) == NULL) {
- + fprintf(stderr,"%s: unable to malloc space for permitted host entry\n",
- + progname);
- + exit(1);
- + }; /* if */
- +
- + new_entry->host_addr = host_addr;
- + key = HASH(host_addr) % TABLE_SIZE;
- + new_entry->next = permitted_hosts[key];
- + permitted_hosts[key] = new_entry;
- + }; /* if */
- +
- + } /* add_host */
- +
- +
- + /*
- + setup_table -- initialise the table of hosts allowed to contact the server.
- + Put in the local machine, and, if a security file is specifed,
- + add each host that is named in the file.
- + */
- + void setup_table()
- + {
- + FILE *host_file;
- + char *file_name;
- + char hostname[HOSTNAMSZ];
- + u_long host_addr;
- + int i;
- +
- + /* Make sure every entry is null */
- + for (i=0; i<TABLE_SIZE; i++)
- + permitted_hosts[i] = NULL;
- +
- + gethostname(hostname,HOSTNAMSZ);
- +
- + if ((host_addr = internet_addr(hostname)) == -1) {
- + fprintf(stderr,"%s: unable to find %s in /etc/hosts or from YP",
- + progname,hostname);
- + exit(1);
- + }; /* if */
- +
- + add_host(host_addr); /* add local host */
- +
- + if (((file_name = getenv("GNU_SECURE")) != NULL && /* security file */
- + (host_file = fopen(file_name,"r")) != NULL)) { /* opened ok */
- + while ((fscanf(host_file,"%s",hostname) != EOF)) /* find a host */
- + if ((host_addr = internet_addr(hostname)) != -1) /* get its internet addr */
- + add_host(host_addr); /* add the addr */
- +
- + fclose(host_file);
- + }; /* if */
- +
- + } /* setup_table */
- +
- +
- + /*
- + internet_init -- initialize server, returning an internet socket that can
- + be listened on.
- + */
- + int internet_init()
- + {
- + int ls; /* socket descriptor */
- + struct servent *sp; /* pointer to service information */
- + struct sockaddr_in server; /* for local socket address */
- + char *ptr; /* ptr to return from getenv */
- +
- + setup_table();
- +
- + /* clear out address structure */
- + bzero((char *)&server,sizeof(struct sockaddr_in));
- +
- + /* Set up address structure for the listen socket. */
- + server.sin_family = AF_INET;
- + server.sin_addr.s_addr = INADDR_ANY;
- +
- + /* Find the information for the gnu server
- + * in order to get the needed port number.
- + */
- + if ((ptr=getenv("GNU_PORT")) != NULL)
- + server.sin_port = htons(atoi(ptr));
- + else if ((sp = getservbyname ("gnuserv", "tcp")) == NULL)
- + server.sin_port = htons(DEFAULT_PORT+getuid());
- + else
- + server.sin_port = sp->s_port;
- +
- + /* Create the listen socket. */
- + if ((ls = socket (AF_INET,SOCK_STREAM, 0)) == -1) {
- + perror(progname);
- + fprintf(stderr,"%s: unable to create socket\n",progname);
- + exit(1);
- + }; /* if */
- +
- + /* Bind the listen address to the socket. */
- + if (bind(ls,&server,sizeof(struct sockaddr_in)) == -1) {
- + perror(progname);
- + fprintf(stderr,"%s: unable to bind socket\n",progname);
- + exit(1);
- + }; /* if */
- +
- + /* Initiate the listen on the socket so remote users
- + * can connect.
- + */
- + if (listen(ls,20) == -1) {
- + perror(progname);
- + fprintf(stderr,"%s: unable to listen\n",progname);
- + exit(1);
- + }; /* if */
- +
- + return(ls);
- +
- + } /* internet_init */
- +
- +
- + /*
- + handle_internet_request -- accept a request from a client and send the information
- + to stdout (the gnu process).
- + */
- + void handle_internet_request(ls)
- + int ls; /* listen socket */
- + {
- + int s;
- + int addrlen = sizeof(struct sockaddr_in);
- + struct sockaddr_in peer; /* for peer socket address */
- +
- + bzero((char *)&peer,sizeof(struct sockaddr_in));
- +
- + if ((s = accept(ls,&peer,&addrlen)) == -1) {
- + perror(progname);
- + fprintf(stderr,"%s: unable to accept\n",progname);
- + exit(1);
- + }; /* if */
- +
- + /* Check that access is allowed - if not return crud to the client */
- + if (!permitted(peer.sin_addr.s_addr)) {
- + send_string(s,"gnudoit: Connection refused\ngnudoit: unable to connect to remote");
- + close(s);
- + return;
- + }; /* if */
- +
- + echo_request(s);
- +
- + } /* handle_internet_request */
- + #endif /* INTERNET_DOMAIN_SOCKETS */
- +
- +
- + #ifdef UNIX_DOMAIN_SOCKETS
- + /*
- + unix_init -- initialize server, returning an unix-domain socket that can
- + be listened on.
- + */
- + int unix_init()
- + {
- + int ls; /* socket descriptor */
- + struct sockaddr_un server; /* unix socket address */
- +
- + if ((ls = socket(AF_UNIX,SOCK_STREAM, 0)) < 0) {
- + perror(progname);
- + fprintf(stderr,"%s: unable to create socket\n",progname);
- + exit(1);
- + }; /* if */
- +
- + /* Set up address structure for the listen socket. */
- + sprintf(server.sun_path,"/tmp/gsrv%d",geteuid());
- + unlink(server.sun_path); /* remove old file if it exists */
- +
- + server.sun_family = AF_UNIX;
- +
- + if (bind(ls,&server,strlen(server.sun_path)+2) < 0) {
- + perror(progname);
- + fprintf(stderr,"%s: unable to bind socket\n",progname);
- + exit(1);
- + }; /* if */
- +
- + chmod(server.sun_path,0700); /* only this user can send commands */
- +
- + if (listen(ls,20) < 0) {
- + perror(progname);
- + fprintf(stderr,"%s: unable to listen\n",progname);
- + exit(1);
- + }; /* if */
- +
- + signal(SIGPIPE,SIG_IGN); /* in case user kills client */
- +
- + return(ls);
- +
- + } /* unix_init */
- +
- +
- + /*
- + handle_unix_request -- accept a request from a client and send the information
- + to stdout (the gnu process).
- + */
- + void handle_unix_request(ls)
- + int ls; /* listen socket */
- + {
- + int s;
- + int len = sizeof(struct sockaddr_un);
- + struct sockaddr_un server; /* for unix socket address */
- +
- + server.sun_family = AF_UNIX;
- +
- + if ((s = accept(ls,&server,&len)) < 0) {
- + perror(progname);
- + fprintf(stderr,"%s: unable to accept\n",progname);
- + }; /* if */
- +
- + echo_request(s);
- +
- + } /* handle_unix_request */
- + #endif /* UNIX_DOMAIN_SOCKETS */
- +
- +
- + main(argc,argv)
- + int argc;
- + char *argv[];
- + {
- + int ils = -1; /* internet domain listen socket */
- + int uls = -1; /* unix domain listen socket */
- + int chan; /* temporary channel number */
- + #ifdef SYSV_IPC
- + struct msgbuf *msgp; /* message buffer */
- + #endif /* SYSV_IPC */
- +
- + progname = argv[0];
- +
- + for(chan=3; chan < _NFILE; close(chan++)) /* close unwanted channels */
- + ;
- +
- + #ifdef SYSV_IPC
- + ipc_init(&msgp); /* get a msqid to listen on, and a message buffer */
- + #endif /* SYSV_IPC */
- +
- + #ifdef INTERNET_DOMAIN_SOCKETS
- + ils = internet_init(); /* get a internet domain socket to listen on */
- + #endif /* INTERNET_DOMAIN_SOCKETS */
- +
- + #ifdef UNIX_DOMAIN_SOCKETS
- + uls = unix_init(); /* get a unix domain socket to listen on */
- + #endif /* UNIX_DOMAIN_SOCKETS */
- +
- + while (1) {
- + #ifdef SYSV_IPC
- + handle_ipc_request(msgp);
- + #else /* NOT SYSV_IPC */
- + int rmask = 1
- + #ifdef UNIX_DOMAIN_SOCKETS
- + + (1 << uls)
- + #endif /* UNIX_DOMAIN_SOCKETS */
- +
- + #ifdef INTERNET_DOMAIN_SOCKETS
- + + (1 << ils)
- + #endif /* INTERNET_DOMAIN_SOCKETS */
- + ;
- +
- + if (select(max2(uls,ils) + 1,&rmask,0,0,0) < 0) {
- + perror(progname);
- + fprintf(stderr,"%s: unable to select\n",progname);
- + exit(1);
- + }; /* if */
- +
- + #ifdef UNIX_DOMAIN_SOCKETS
- + if (rmask & (1 << uls)) /* from unix domain socket (client process) */
- + handle_unix_request(uls);
- + #endif /* UNIX_DOMAIN_SOCKETS */
- +
- + #ifdef INTERNET_DOMAIN_SOCKETS
- + if (rmask & (1 << ils)) /* from internet domain socket (client process) */
- + handle_internet_request(ils);
- + #endif /* INTERNET_DOMAIN_SOCKETS */
- +
- + if (rmask & 1) /* from stdin (gnu process) */
- + handle_response();
- + #endif /* NOT SYSV_IPC */
- + }; /* while */
- +
- + } /* main */
- +
- + #endif /* SYSV_IPC || UNIX_DOMAIN_SOCKETS || INTERNET_DOMAIN_SOCKETS */
- *** ./lib-src/gnudoit.c Thu May 21 11:32:03 1998
- --- ../emacs-19.34/./lib-src/gnudoit.c Fri May 15 10:38:38 1998
- ***************
- *** 0 ****
- --- 1,139 ----
- + /* -*-C-*-
- + Client code to locally and remotely evaluate lisp forms using GNU Emacs.
- +
- + This file is part of GNU Emacs.
- +
- + Copying is permitted under those conditions described by the GNU
- + General Public License.
- +
- + Copyright (C) 1989 Free Software Foundation, Inc.
- +
- + Author: Andy Norman (ange@hplb.hpl.hp.com).
- +
- + Please mail bugs and suggestions to the author at the above address.
- + */
- +
- + static char rcsid [] = "$Header: gnudoit.c,v 1.5 89/07/24 12:47:53 ange Exp $";
- +
- + #include "gnuserv.h"
- +
- + #if !defined(SYSV_IPC) && !defined(UNIX_DOMAIN_SOCKETS) && !defined(INTERNET_DOMAIN_SOCKETS)
- + main ()
- + {
- + fprintf (stderr,"Sorry, the Emacs server is only supported on systems that have\n");
- + fprintf (stderr,"Unix Domain sockets, Internet Domain sockets or System V IPC.\n");
- + exit (1);
- + } /* main */
- + #else /* SYSV_IPC || UNIX_DOMAIN_SOCKETS || INTERNET_DOMAIN_SOCKETS */
- +
- + main(argc,argv)
- + int argc;
- + char *argv[];
- + {
- + int starting_line = 1; /* line to start editing at */
- + int qflg = 0; /* don't wait around for gnu emacs to eval cmd */
- + int errflg = 0; /* option error */
- + int c; /* char from getopt */
- + int s; /* socket / msqid to server */
- + #ifdef INTERNET_DOMAIN_SOCKETS
- + char remotehost[HOSTNAMSZ]; /* remote hostname */
- + int hflg = 0; /* hostname given on command line */
- + u_short port = 0; /* port number */
- + char *ptr; /* return from getenv */
- + #endif /* INTERNET_DOMAIN_SOCKETS */
- + #ifdef SYSV_IPC
- + struct msgbuf *msgp; /* message */
- + #endif /* SYSV_IPC */
- +
- + progname = argv[0];
- +
- + while ((c = getopt(argc, argv,
- + #ifdef INTERNET_DOMAIN_SOCKETS
- + "qh:p:"
- + #else /* !INTERNET_DOMAIN_SOCKETS */
- + "q"
- + #endif /* !INTERNET_DOMAIN_SOCKETS */
- + )) != EOF)
- + switch (c) {
- + #ifdef INTERNET_DOMAIN_SOCKETS
- + case 'h': /* host name specified */
- + strcpy(remotehost,optarg);
- + hflg++;
- + break;
- + case 'p': /* port number specified */
- + port = atoi(optarg);
- + break;
- + #endif /* INTERNET_DOMAIN_SOCKETS */
- + case 'q': /* quick mode specified */
- + qflg++;
- + break;
- + case '?':
- + errflg++;
- + }; /* switch */
- +
- + if (errflg) {
- + fprintf(stderr,
- + #ifdef INTERNET_DOMAIN_SOCKETS
- + "usage: %s [-q] [-h hostname] [-p port] [sexpr]...\n",
- + #else /* !INTERNET_DOMAIN_SOCKETS */
- + "usage: %s [-q] [sexpr]...\n",
- + #endif /* !INTERNET_DOMAIN_SOCKETS */
- + progname);
- + exit (1);
- + }; /* if */
- +
- + #ifdef INTERNET_DOMAIN_SOCKETS
- + if (!hflg) {
- + if((ptr=getenv("GNU_HOST")) != NULL)
- + strcpy(remotehost,ptr);
- + else
- + gethostname(remotehost,HOSTNAMSZ); /* use this host by default */
- + }; /* if */
- +
- + if (port == 0 && (ptr=getenv("GNU_PORT")) != NULL)
- + port = atoi(ptr);
- +
- + #ifdef UNIX_DOMAIN_SOCKETS
- + if (!strcmp(remotehost,"unix"))
- + s = connect_to_unix_server();
- + else
- + #endif /* UNIX_DOMAIN_SOCKETS */
- + s = connect_to_internet_server(remotehost,port);
- + #else /* !INTERNET_DOMAIN_SOCKETS */
- + #ifdef UNIX_DOMAIN_SOCKETS
- + s = connect_to_unix_server();
- + #endif /* UNIX_DOMAIN_SOCKETS */
- + #ifdef SYSV_IPC
- + if ((msgp = (struct msgbuf *) malloc(sizeof *msgp + BUFSIZ)) == NULL) {
- + fprintf(stderr,"%s: not enough memory for message buffer\n",progname);
- + exit(1);
- + }; /* if */
- +
- + msgp->mtext[0] = '\0'; /* ready for later strcats */
- + s = connect_to_ipc_server();
- + #endif /* SYSV_IPC */
- + #endif /* !INTERNET_DOMAIN_SOCKETS */
- +
- + if (qflg) {
- + send_string(s,"(server-eval-quickly '(progn ");
- + }
- + else {
- + send_string(s,"(server-eval '(progn ");
- + };
- +
- + for (; optind < argc; optind++)
- + send_string(s,argv[optind]);
- +
- + send_string(s,"))");
- +
- + #ifdef SYSV_IPC
- + disconnect_from_ipc_server(s,msgp,!qflg);
- + #else /* !SYSV_IPC */
- + disconnect_from_server(s,!qflg);
- + #endif /* !SYSV_IPC */
- +
- + exit(0);
- +
- + } /* main */
- +
- + #endif /* SYSV_IPC || UNIX_DOMAIN_SOCKETS || INTERNET_DOMAIN_SOCKETS */
- *** ./lib-src/gnuslib.c Thu May 21 11:32:03 1998
- --- ../emacs-19.34/./lib-src/gnuslib.c Fri May 15 10:39:05 1998
- ***************
- *** 0 ****
- --- 1,247 ----
- + /* -*-C-*-
- + Common library code for the GNU Emacs server and client.
- +
- + This file is part of GNU Emacs.
- +
- + Copying is permitted under those conditions described by the GNU
- + General Public License.
- +
- + Copyright (C) 1989 Free Software Foundation, Inc.
- +
- + Author: Andy Norman (ange@hplb.hpl.hp.com), based on
- + 'etc/server.c' and 'etc/emacsclient.c' from the 18.52 GNU
- + Emacs distribution.
- +
- + Please mail bugs and suggestions to the author at the above address.
- + */
- +
- + static char rcsid [] = "$Header: gnuslib.c,v 1.6 89/09/28 12:47:34 ange Exp $";
- +
- + #include "gnuserv.h"
- +
- + char *progname = NULL;
- +
- + #ifdef SYSV_IPC
- + /*
- + connect_to_ipc_server -- establish connection with server process via SYSV IPC
- + Returns msqid for server if successful.
- + */
- + int connect_to_ipc_server()
- + {
- + int s; /* connected msqid */
- + key_t key; /* message key */
- + char buf[BUFSIZ]; /* buffer for filename */
- +
- + sprintf(buf,"/tmp/gsrv%d",geteuid());
- + creat(buf,0600);
- + key = ftok(buf,1);
- +
- + if ((s = msgget(key,0600)) == -1) {
- + perror(progname);
- + fprintf(stderr,"%s: unable to access msg queue\n",progname);
- + exit(1);
- + }; /* if */
- +
- + return(s);
- +
- + } /* connect_to_ipc_server */
- +
- +
- + /*
- + disconnect_from_ipc_server -- inform the server that sending has finished,
- + and wait for its reply.
- + */
- + void disconnect_from_ipc_server(s,msgp,echo)
- + int s;
- + struct msgbuf *msgp;
- + int echo;
- + {
- + int len; /* length of received message */
- +
- + send_string(s,"\n"); /* newline terminates this message */
- + msgp->mtype = 1;
- +
- + if(msgsnd(s,msgp,strlen(msgp->mtext)+1,0) < 0) {
- + perror(progname);
- + fprintf(stderr,"%s: unable to send message to server\n",progname);
- + exit(1);
- + }; /* if */
- +
- + if((len = msgrcv(s,msgp,BUFSIZ,getpid(),0)) < 0) {
- + perror(progname);
- + fprintf(stderr,"%s: unable to receive message from server\n",progname);
- + exit(1);
- + }; /* if */
- +
- + if (echo) {
- + msgp->mtext[len] = '\0'; /* string terminate message */
- + printf("%s\n",msgp->mtext);
- + }; /* if */
- +
- + } /* disconnect_from_ipc_server */
- + #endif SYSV_IPC
- +
- +
- + #if defined(INTERNET_DOMAIN_SOCKETS) || defined(UNIX_DOMAIN_SOCKETS)
- + /*
- + send_string -- send string to socket.
- + */
- + void send_string(s,msg)
- + int s;
- + char *msg;
- + {
- + if (send(s,msg,strlen(msg),0) < 0) {
- + perror(progname);
- + fprintf(stderr,"%s: unable to send\n",progname);
- + exit(1);
- + }; /* if */
- +
- + } /* send_string */
- + #endif /* INTERNET_DOMAIN_SOCKETS || UNIX_DOMAIN_SOCKETS */
- +
- +
- + #ifdef UNIX_DOMAIN_SOCKETS
- + /*
- + connect_to_unix_server -- establish connection with server process via a unix-
- + domain socket. Returns socket descriptor for server
- + if successful.
- + */
- + int connect_to_unix_server()
- + {
- + int s; /* connected socket descriptor */
- + struct sockaddr_un server; /* for unix connections */
- +
- + if ((s = socket(AF_UNIX,SOCK_STREAM,0)) < 0) {
- + perror(progname);
- + fprintf(stderr,"%s: unable to create socket\n",progname);
- + exit(1);
- + }; /* if */
- +
- + server.sun_family = AF_UNIX;
- + sprintf(server.sun_path,"/tmp/gsrv%d",geteuid());
- +
- + if (connect(s,&server,strlen(server.sun_path)+2) < 0) {
- + perror(progname);
- + fprintf(stderr,"%s: unable to connect to local\n",progname);
- + exit(1);
- + }; /* if */
- +
- + return(s);
- +
- + } /* connect_to_unix_server */
- + #endif /* UNIX_DOMAIN_SOCKETS */
- +
- +
- + #ifdef INTERNET_DOMAIN_SOCKETS
- + /*
- + internet_addr -- return the internet addr of the hostname or
- + internet address passed. Return -1 on error.
- + */
- + u_long internet_addr(host)
- + char *host;
- + {
- + struct hostent *hp; /* pointer to host info for remote host */
- + u_long host_addr; /* host address */
- +
- + if ((host_addr = inet_addr(host)) != -1)
- + return host_addr;
- + else if ((hp = gethostbyname(host)) != NULL)
- + return ((struct in_addr *)(hp->h_addr))->s_addr;
- + else
- + return -1;
- +
- + } /* internet_addr */
- +
- +
- + /*
- + connect_to_internet_server -- establish connection with server process via
- + an internet domain socket. Returns socket
- + descriptor for server if successful.
- + */
- + int connect_to_internet_server(serverhost,port)
- + char *serverhost;
- + u_short port;
- + {
- + int s; /* connected socket descriptor */
- + struct servent *sp; /* pointer to service information */
- + struct sockaddr_in peeraddr_in; /* for peer socket address */
- +
- + /* clear out address structures */
- + bzero((char *)&peeraddr_in,sizeof(struct sockaddr_in));
- +
- + /* Set up the peer address to which we will connect. */
- + peeraddr_in.sin_family = AF_INET;
- +
- + /* look up the server host's internet address */
- + if ((peeraddr_in.sin_addr.s_addr = internet_addr(serverhost)) == -1) {
- + fprintf(stderr,"%s: unable to find %s in /etc/hosts or from YP\n",
- + progname,serverhost);
- + exit(1);
- + }; /* if */
- +
- + if (port == 0) {
- + if ((sp = getservbyname ("gnuserv","tcp")) == NULL)
- + peeraddr_in.sin_port = htons(DEFAULT_PORT+getuid());
- + else
- + peeraddr_in.sin_port = sp->s_port;
- + } /* if */
- + else
- + peeraddr_in.sin_port = htons(port);
- +
- + /* Create the socket. */
- + if ((s = socket (AF_INET,SOCK_STREAM, 0))== -1) {
- + perror(progname);
- + fprintf(stderr,"%s: unable to create socket\n",progname);
- + exit(1);
- + }; /* if */
- +
- + /* Try to connect to the remote server at the address
- + * which was just built into peeraddr.
- + */
- + if (connect(s, &peeraddr_in, sizeof(struct sockaddr_in)) == -1) {
- + perror(progname);
- + fprintf(stderr, "%s: unable to connect to remote\n",progname);
- + exit(1);
- + }; /* if */
- +
- + return(s);
- +
- + } /* connect_to_internet_server */
- + #endif /* INTERNET_DOMAIN_SOCKETS */
- +
- +
- + #if defined(INTERNET_DOMAIN_SOCKETS) || defined(UNIX_DOMAIN_SOCKETS)
- + /*
- + disconnect_from_server -- inform the server that sending has finished, and wait for
- + its reply.
- + */
- + void disconnect_from_server(s,echo)
- + int s;
- + int echo;
- + {
- + char buffer[REPLYSIZ];
- + int length;
- +
- + send_string(s,"\n"); /* make sure server gets string */
- +
- + if (shutdown(s,1) == -1) {
- + perror(progname);
- + fprintf(stderr, "%s: unable to shutdown socket\n",progname);
- + exit(1);
- + }; /* if */
- +
- + while((length = recv(s,buffer,REPLYSIZ,0)) > 0) {
- + buffer[length] = '\0';
- + if (echo) printf("%s",buffer);
- + }; /* while */
- +
- + if (echo) putchar('\n');
- +
- + if(length < 0) {
- + perror(progname);
- + fprintf(stderr,"%s: unable to read the reply from the server\n",progname);
- + exit(1);
- + }; /* if */
- +
- + } /* disconnect_from_server */
- + #endif /* INTERNET_DOMAIN_SOCKETS || UNIX_DOMAIN_SOCKETS */
- *** ./Makefile.in Tue Aug 20 00:12:19 1996
- --- ../emacs-19.34/./Makefile.in Fri May 15 10:42:41 1998
- ***************
- *** 253,264 ****
- .RECURSIVE: ${SUBDIR}
-
- ${SUBDIR}: ${SUBDIR_MAKEFILES} FRC
- ! cd $@; $(MAKE) all $(MFLAGS) \
- CC='${CC}' CFLAGS='${CFLAGS}' CPPFLAGS='${CPPFLAGS}' \
- LDFLAGS='${LDFLAGS}' MAKE='${MAKE}'
-
- blessmail: ${SUBDIR_MAKEFILES} src FRC
- ! cd lib-src; $(MAKE) maybe-blessmail $(MFLAGS) \
- MAKE='${MAKE}' archlibdir='$(archlibdir)'
-
- Makefile: Makefile.in config.status
- --- 253,264 ----
- .RECURSIVE: ${SUBDIR}
-
- ${SUBDIR}: ${SUBDIR_MAKEFILES} FRC
- ! cd $@; $(MAKE) $(MFLAGS) all \
- CC='${CC}' CFLAGS='${CFLAGS}' CPPFLAGS='${CPPFLAGS}' \
- LDFLAGS='${LDFLAGS}' MAKE='${MAKE}'
-
- blessmail: ${SUBDIR_MAKEFILES} src FRC
- ! cd lib-src; $(MAKE) $(MFLAGS) maybe-blessmail \
- MAKE='${MAKE}' archlibdir='$(archlibdir)'
-
- Makefile: Makefile.in config.status
- ***************
- *** 304,310 ****
- ### to ensure that install-arch-indep finishes before this starts.
- install-arch-dep: mkdir
- (cd lib-src; \
- ! $(MAKE) install $(MFLAGS) prefix=${prefix} \
- exec_prefix=${exec_prefix} bindir=${bindir} \
- libexecdir=${libexecdir} archlibdir=${archlibdir})
- ${INSTALL_PROGRAM} src/emacs ${bindir}/emacs-${version}
- --- 304,310 ----
- ### to ensure that install-arch-indep finishes before this starts.
- install-arch-dep: mkdir
- (cd lib-src; \
- ! $(MAKE) $(MFLAGS) install prefix=${prefix} \
- exec_prefix=${exec_prefix} bindir=${bindir} \
- libexecdir=${libexecdir} archlibdir=${archlibdir})
- ${INSTALL_PROGRAM} src/emacs ${bindir}/emacs-${version}
- ***************
- *** 471,479 ****
- ### `make distclean' should leave only the files that were in the
- ### distribution.
- top_distclean=\
- ! rm -f config.status config.cache config.log ; \
- rm -f Makefile ${SUBDIR_MAKEFILES} ; \
- ! (cd lock && (rm * || true))
- distclean: FRC
- (cd src; $(MAKE) $(MFLAGS) distclean)
- (cd oldXMenu; $(MAKE) $(MFLAGS) distclean)
- --- 471,479 ----
- ### `make distclean' should leave only the files that were in the
- ### distribution.
- top_distclean=\
- ! -rm -f config.status config.cache config.log ; \
- rm -f Makefile ${SUBDIR_MAKEFILES} ; \
- ! (test -d lock && cd lock && (rm * || true))
- distclean: FRC
- (cd src; $(MAKE) $(MFLAGS) distclean)
- (cd oldXMenu; $(MAKE) $(MFLAGS) distclean)
- Binary files ./site-lisp/gnuserv.elc and ../emacs-19.34/./site-lisp/gnuserv.elc differ
- *** ./site-lisp/gnuserv.el Thu May 21 11:32:03 1998
- --- ../emacs-19.34/./site-lisp/gnuserv.el Fri May 15 10:37:38 1998
- ***************
- *** 0 ****
- --- 1,366 ----
- + ; Lisp Interface code between GNU Emacs and gnuserv.
- + ;
- + ; This file is part of GNU Emacs.
- + ;
- + ; Copying is permitted under those conditions described by the GNU
- + ; General Public License.
- + ;
- + ; Copyright (C) 1989 Free Software Foundation, Inc.
- + ;
- + ; Author: Andy Norman (ange@hplb.hpl.hp.com) based on
- + ; 'lisp/server.el' from the 18.52 GNU Emacs distribution.
- + ;
- + ; Please mail bugs and suggestions to the author at the above address.
- +
- +
- + (defconst gnuserv-rcs-header-id "$Header: /usr/xtmp/khera/emacs-19.12/site-lisp/gnuserv.el,v 1.3 1993/06/03 15:11:00 khera Exp $")
- +
- + (provide 'gnuserv)
- +
- + (defvar server-program (concat exec-directory "gnuserv")
- + "*The program to use as the edit server")
- +
- + (defvar server-process nil
- + "the current server process")
- +
- + (defvar server-string ""
- + "the last input string from the server")
- +
- + (defvar current-client nil
- + "the client we are currently talking to")
- +
- + (defvar server-clients nil
- + "List of current server clients.
- + Each element is (CLIENTID BUFFER...) where CLIENTID is an integer
- + that can be given to the server process to identify a client.
- + When a buffer is killed, it is removed from this list.")
- +
- + (defvar server-buffer-clients nil
- + "List of clientids for clients requesting editing of current buffer.")
- +
- + (make-variable-buffer-local 'server-buffer-clients)
- + (setq-default server-buffer-clients nil)
- + (or (assq 'server-buffer-clients minor-mode-alist)
- + (setq minor-mode-alist (cons '(server-buffer-clients " Server") minor-mode-alist)))
- +
- + (defun server-log (string)
- + "If a *server* buffer exists, write STRING to it for logging purposes."
- + (if (get-buffer "*server*")
- + (save-excursion
- + (set-buffer "*server*")
- + (goto-char (point-max))
- + (insert string)
- + (or (bolp) (newline)))))
- +
- +
- + (defun server-sentinel (proc msg)
- + (cond ((eq (process-status proc) 'exit)
- + (server-log (message "Server subprocess exited")))
- + ((eq (process-status proc) 'signal)
- + (server-log (message "Server subprocess killed")))))
- +
- +
- + (defun server-process-display-error (string)
- + "When an error has been reported from the server, display the error in a
- + pop-up window."
- + (let ((cur (selected-window))
- + (pop-up-windows t))
- + (pop-to-buffer (get-buffer-create "*server*"))
- + (set-window-start (selected-window) (point))
- + (server-log string)
- + (select-window cur)))
- +
- +
- + (defun server-process-filter (proc string)
- + "Process incoming requests from the server for GNU Emacs to do some actions."
- + (setq server-string (concat server-string string))
- + (if (string-match "\n$" server-string) ;wait till request ends with a newline
- + (if (string-match "^[0-9]+" server-string) ;client request id
- + (progn
- + (server-log server-string)
- + (let ((header (read-from-string server-string)))
- + (setq current-client (car header))
- + (condition-case oops
- + (eval (car (read-from-string server-string (cdr header))))
- + (error (setq server-string "")
- + (server-write-to-client current-client oops)
- + (setq current-client nil)
- + (signal (car oops) (cdr oops)))
- + (quit (setq server-string "")
- + (server-write-to-client current-client oops)
- + (setq current-client nil)
- + (signal 'quit nil)))
- + (setq server-string "")))
- + (progn ;error string from server
- + (server-process-display-error server-string)
- + (setq server-string "")))))
- +
- +
- + (defun server-release-outstanding-buffers ()
- + "Release all buffers that have clients waiting for them to be finished."
- + (interactive)
- + (while server-clients
- + (let ((buffer (nth 1 (car server-clients)))) ;need to do this for all buffers
- + (server-buffer-done buffer)))) ; destructively modifies server-clients
- +
- +
- + (defun server-start (&optional leave-dead)
- + "Allow this Emacs process to be a server for client processes.
- + This starts a server communications subprocess through which
- + client \"editors\" can send editing commands to this Emacs job.
- +
- + Prefix arg means just kill any existing server communications subprocess."
- + (interactive "P")
- + ;; kill it dead!
- + (if server-process
- + (progn
- + (server-release-outstanding-buffers)
- + (set-process-sentinel server-process nil)
- + (condition-case ()
- + (delete-process server-process)
- + (error nil))))
- + ;; If we already had a server, clear out associated status.
- + (if leave-dead
- + nil
- + (if server-process
- + (server-log (message "Restarting server")))
- + (setq server-string "")
- + (setq current-client nil)
- + (let ((process-connection-type t))
- + (setq server-process (start-process "server" nil server-program)))
- + (set-process-sentinel server-process 'server-sentinel)
- + (set-process-filter server-process 'server-process-filter)
- + (process-kill-without-query server-process)))
- +
- +
- + (defun server-write-to-client (client form)
- + "Write the given form to the given client via the server process."
- + (if (and client
- + (eq (process-status server-process) 'run))
- + (let ((s (format "%s:%s\n" client form)))
- + (send-string server-process s)
- + (server-log s))))
- +
- +
- + (defun server-eval (form)
- + "Evaluate form and return result to client."
- + (server-write-to-client current-client (eval form))
- + (setq current-client nil))
- +
- +
- + (defun server-eval-quickly (form)
- + "Let client know that we've received the request, but eval the form
- + afterwards in order to not keep the client waiting."
- + (server-write-to-client current-client nil)
- + (setq current-client nil)
- + (eval form))
- +
- +
- + (defun server-make-window-visible ()
- + "Try to make the window visible."
- + (make-frame-visible))
- +
- +
- + (defun server-find-file (file)
- + "Edit file FILENAME.
- + Switch to a buffer visiting file FILENAME,
- + creating one if none already exists."
- + (let ((obuf (get-file-buffer file)))
- + (if (and obuf (set-buffer obuf))
- + (if (file-exists-p file)
- + (if (or (not (verify-visited-file-modtime obuf))
- + (buffer-modified-p obuf))
- + (revert-buffer t nil))
- + (if (y-or-n-p
- + (concat "File no longer exists: "
- + file
- + ", write buffer to file? "))
- + (write-file file)))
- + (set-buffer (find-file-noselect file))))
- + (switch-to-buffer (current-buffer)))
- +
- +
- + (defun server-edit-files-quickly (l)
- + "For each (lineno . file) pair in the given list, edit the file and goto the
- + given line number. Note that unlike server-edit-files, no information is saved
- + about clients waiting for this buffer to be killed."
- + (server-write-to-client current-client nil)
- + (setq current-client nil)
- + (server-make-window-visible)
- + (while l
- + (let ((line (car (car l)))
- + (path (cdr (car l))))
- + (server-find-file path)
- + (goto-line line))
- + (setq l (cdr l))))
- +
- +
- + (defun server-edit-files (l)
- + "For each (lineno . file) pair in the given list, edit the given file for the
- + client and save enough information such that server-kill-buffer can let the client
- + know when the buffer has been finished with."
- + (server-make-window-visible)
- + (while l
- + (let ((line (car (car l)))
- + (path (cdr (car l))))
- + (server-find-file path)
- + (let ((old-clients (assq current-client server-clients))
- + (buffer (current-buffer)))
- + (goto-line line)
- + (setq server-buffer-clients
- + (cons current-client server-buffer-clients))
- + (if old-clients ;client already waiting for buffers?
- + (nconc old-clients (list buffer)) ;yes -- append this one as well
- + (setq server-clients ;nope -- make a new record
- + (cons (list current-client buffer)
- + server-clients)))))
- + (setq l (cdr l)))
- + (message (substitute-command-keys
- + "When done with a buffer, type \\[server-edit].")))
- +
- +
- + (defun server-get-buffer (buffer)
- + "One arg, a string or a buffer. Return either a buffer object or
- + throw an error if the buffer named was not a buffer."
- + (if (null buffer)
- + (current-buffer)
- + (let ((buf (get-buffer buffer)))
- + (if (null buf)
- + (if (stringp buffer)
- + (error "No buffer named %s" buffer)
- + (error "Invalid buffer argument"))
- + buf))))
- +
- +
- + (defun server-kill-buffer (buffer)
- + "One arg, a string or a buffer. Get rid of the specified buffer.
- + NOTE: This function has been enhanced to allow for remote editing
- + in the following way:
- +
- + If the buffer is waited upon by one or more clients, and a client is
- + not waiting for other buffers to be killed, then the client is told
- + that the buffer has been killed."
- + (interactive "bKill buffer ")
- + (setq buffer (server-get-buffer buffer))
- + (if (buffer-name buffer)
- + (save-excursion
- + (set-buffer buffer)
- + (let ((old-clients server-clients))
- + (server-real-kill-buffer buffer) ;try to kill it
- + (if (buffer-name buffer) ;succeeded in killing?
- + nil ;nope
- + (while old-clients
- + (let ((client (car old-clients)))
- + (delq buffer client)
- + (if (cdr client) ;pending buffers?
- + nil ;yep
- + (server-write-to-client (car client) nil) ;nope, tell client
- + (setq server-clients (delq client server-clients))))
- + (setq old-clients (cdr old-clients))))))))
- +
- +
- + (defun server-kill-all-local-variables ()
- + "Eliminate all the buffer-local variable values of the current buffer.
- + This buffer will then see the default values of all variables.
- + NOTE: This function has been modified to ignore the variable
- + server-buffer-clients."
- + (let ((clients server-buffer-clients))
- + (server-real-kill-all-local-variables)
- + (if clients
- + (setq server-buffer-clients clients))))
- +
- +
- + (or (fboundp 'server-real-kill-buffer)
- + (fset 'server-real-kill-buffer (symbol-function 'kill-buffer)))
- +
- + (fset 'kill-buffer 'server-kill-buffer)
- +
- + (or (fboundp 'server-real-kill-all-local-variables)
- + (fset 'server-real-kill-all-local-variables
- + (symbol-function 'kill-all-local-variables)))
- +
- + (fset 'kill-all-local-variables 'server-kill-all-local-variables)
- +
- +
- + (defun server-buffer-done (buffer)
- + "Mark BUFFER as \"done\" for its client(s).
- + Buries the buffer, and returns another server buffer
- + as a suggestion for what to select next."
- + (let ((next-buffer nil)
- + (old-clients server-clients))
- + (while old-clients
- + (let ((client (car old-clients)))
- + (or next-buffer
- + (setq next-buffer (nth 1 (memq buffer client))))
- + (delq buffer client)
- + ;; If client now has no pending buffers,
- + ;; tell it that it is done, and forget it entirely.
- + (if (cdr client)
- + nil
- + (server-write-to-client (car client) nil)
- + (setq server-clients (delq client server-clients))))
- + (setq old-clients (cdr old-clients)))
- + (if (buffer-name buffer)
- + (save-excursion
- + (set-buffer buffer)
- + (setq server-buffer-clients nil)))
- + (bury-buffer buffer)
- + next-buffer))
- +
- +
- + (defun mh-draft-p (buffer)
- + "Return non-nil if this BUFFER is an mh <draft> file.
- + Since MH deletes draft *BEFORE* it is edited, the server treats them specially."
- + ;; This may not be appropriately robust for all cases.
- + (string= (buffer-name buffer) "draft"))
- +
- +
- + (defun server-done ()
- + "Offer to save current buffer, mark it as \"done\" for clients,
- + bury it, and return a suggested buffer to select next."
- + (let ((buffer (current-buffer)))
- + (if server-buffer-clients
- + (progn
- + (if (mh-draft-p buffer)
- + (progn (save-buffer)
- + (write-region (point-min) (point-max)
- + (concat buffer-file-name "~"))
- + (kill-buffer buffer))
- + (if (and (buffer-modified-p)
- + (y-or-n-p (concat "Save file " buffer-file-name "? ")))
- + (save-buffer buffer)))
- + (server-buffer-done buffer)))))
- +
- +
- + (defun server-edit (&optional arg)
- + "Switch to next server editing buffer; say \"Done\" for current buffer.
- + If a server buffer is current, it is marked \"done\" and optionally saved.
- + MH <draft> files are always saved and backed up, no questions asked.
- + When all of a client's buffers are marked as \"done\", the client is notified.
- +
- + If invoked with a prefix argument, or if there is no server process running,
- + starts server process and that is all. Invoked by \\[server-edit]."
- + (interactive "P")
- + (if (or arg
- + (not server-process)
- + (memq (process-status server-process) '(signal exit)))
- + (server-start nil)
- + (server-switch-buffer (server-done))))
- +
- + (defun server-switch-buffer (next-buffer)
- + "Switch to another buffer, preferably one that has a client.
- + Arg NEXT-BUFFER is a suggestion; if it is a live buffer, use it."
- + (if next-buffer
- + (if (and (bufferp next-buffer)
- + (buffer-name next-buffer))
- + (switch-to-buffer next-buffer)
- + ;; If NEXT-BUFFER is a dead buffer,
- + ;; remove the server records for it
- + ;; and try the next surviving server buffer.
- + (server-switch-buffer
- + (server-buffer-done next-buffer)))
- + (if server-clients
- + (server-switch-buffer (nth 1 (car server-clients)))
- + (switch-to-buffer (other-buffer)))))
- +
- + (global-set-key "\C-x#" 'server-edit)
- *** ./configure Tue Aug 20 00:11:26 1996
- --- ../emacs-19.34/./configure Thu May 21 11:43:36 1998
- ***************
- *** 1219,1224 ****
- --- 1219,1236 ----
- mips-sgi-irix4* )
- machine=iris4d opsys=irix4-0
- ;;
- + mips-sgi-irix6.4 | mips-sgi-irix6.5 )
- + machine=iris4d opsys=irix6-4
- + NON_GNU_CPP='cc -E'
- + CPP=/lib/cpp
- + _ABIN32=1
- + ;;
- + mips-sgi-irix6.x )
- + machine=iris4d opsys=irix6-x
- + NON_GNU_CPP='cc -E'
- + CPP=/lib/cpp
- + _ABIN32=1
- + ;;
- mips-sgi-irix6* )
- machine=iris4d opsys=irix6-0
- NON_GNU_CPP=/lib/cpp
- ***************
- *** 3641,3647 ****
- builtin and then its argument prototype would still apply. */
- char $ac_func();
-
- ! int main() { return 0; }
- int t() {
-
- /* The GNU C library defines this for functions which it implements
- --- 3653,3659 ----
- builtin and then its argument prototype would still apply. */
- char $ac_func();
-
- ! int main() { return t(); }
- int t() {
-
- /* The GNU C library defines this for functions which it implements
-